<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link href="${ctx}/styles/aux_window.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>

<script type="text/javascript">
	<c:if test="${ !empty isEdit}">
		parent.areaObj.flushIframe();
		parent.areaObj.closeWindowOnCheck();
	</c:if>

	var POLICESTATION = ["${ctx}/house_coWorkerPoliceAction.do","policeStation_"];
	var BOTTOMORG = ["${ctx}/house_coWorkerStreetAction.do","streetOrg_"];
	var STREETORG= ["${ctx}/house_coWorkerResidentAction.do","bottomOrg_"];

	var oldFormSerial = null; //表单内容是否改变标识
	/******select onchange事件*******/
	function onChangeEventHandle(obj,name){
		var type = eval(name);
		//如果选中的为'请选择'，则要退出
		if(obj.value == null || obj.value == ""){
			setFormValueNull(type);
			return;
		}
		var url = type[0] + "?method=findCoWorkerById";
		var str = "coWorkerId=" + obj.value;
		new Ajax.Request(url,
		                    {method: 'post', parameters: str, onComplete: function(result){
			                    	var objText = eval('(' + result.responseText + ')');
			                    	$(type[1] + "telephone").innerText = objText.telephone;
			                    	$(type[1] + "contactor").innerText = objText.contactor;
			                    	$(type[1] + "address").innerText = objText.address;
		                    	}
		                    }
	                    );
	}

	/****提交表单*******/
	function submitForm(){
		document.forms[0].submit();
	}
	/*****是否允许提交表单*******/
	function allowClose(){
		return getFormValue() == oldFormSerial;
	}

	/******获取表单的值*******/
	function getFormValue(){
		var formValue = "";
		formValue += $('policeStationID').value;
		formValue += $('streetOrgID').value;
		formValue += $('bottomOrgID').value;
		return formValue;
	}
	function setFormValueNull(type){
       	$(type[1] + "telephone").innerText = "";
       	$(type[1] + "contactor").innerText = "";
       	$(type[1] + "address").innerText = "";
	}
	function init(){
		oldFormSerial = getFormValue();
		<c:if test="${ !empty isSave}">
			parent.areaObj.setSaveClick();  //设置按钮可用
			parent.areaObj.flushIframe(); //刷新父页面
		</c:if>
	}
</script>
</head>
<body onload="init();">
<form action="${ctx}/house_areaAction.do?method=editGovtRelation" method="post">
	<input type="hidden" id="isEdit" name="isEdit" value="">
	<input type="hidden" id="isSave" name="isSave" value="">
		<div  id="tab_subMenu3">
               <table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
                      <tr>
                        <td><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">
                      <tr>
                        <td><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
                          <tr>
                            <td colspan="4" class="aux_titletable">${key.house_area_policeStation}</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.house_area_policeStation_name}：</td>
                            <td class="aux_intable_td2">
                            <pms:unitedSelect name="policeStationID" id="policeStationID"
                            	optionLabel="name"
                            	optionValue="coWorkerID"
                            	selectText="请选择"
                            	value="${areavo.policeStation.coWorkerID}"
                            	dataList="${policeStationList}"
                            	onChange="onChangeEventHandle(this,'POLICESTATION');"
                            	style="width:150px"
                            	>
                            </pms:unitedSelect>
                            </td>
                            <td class="aux_intable_td1">${key.house_area_policeStation_telephone}：</td>
                            <td class="aux_intable_td2" id="policeStation_telephone">${areavo.policeStation.telephone}</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.house_area_policeStation_contactor}：</td>
                            <td class="aux_intable_td2" id="policeStation_contactor">${areavo.policeStation.contactor}</td>
                            <td class="aux_intable_td1">${key.house_area_policeStation_address}：</td>
                            <td class="aux_intable_td2" id="policeStation_address">${areavo.policeStation.address}</td>
                          </tr>
                          <tr>
                            <td colspan="4" class="aux_titletable">${key.house_streetOrg}</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.house_streetOrg_name}：</td>
                            <td class="aux_intable_td2">
                            <pms:unitedSelect name="streetOrgID" id="streetOrgID"
								optionLabel="name"
								optionValue="coWorkerID"
								selectText="请选择"
								value="${areavo.streetOrg.coWorkerID}"
								dataList="${streetOrgList}"
								onChange="onChangeEventHandle(this,'BOTTOMORG');"
								style="width:150px"
								>
                            </pms:unitedSelect>
                            </td>
                            <td class="aux_intable_td1">${key.house_streetOrg_telephone}：</td>
                            <td class="aux_intable_td2" id="streetOrg_telephone">${areavo.streetOrg.telephone}</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.house_streetOrg_contactor}：</td>
                            <td class="aux_intable_td2" id="streetOrg_contactor">${areavo.streetOrg.contactor}</td>
                            <td class="aux_intable_td1">${key.house_streetOrg_address}：</td>
                            <td class="aux_intable_td2" id="streetOrg_address">${areavo.streetOrg.address}</td>
                          </tr>
                          <tr>
                            <td colspan="4" class="aux_titletable">${key.house_bottomOrg}</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.house_bottomOrg_name}：</td>
                            <td class="aux_intable_td2">
                            <pms:unitedSelect name="bottomOrgID" id="bottomOrgID"
								optionLabel="name"
								optionValue="coWorkerID"
								selectText="请选择"
								dataList="${bottomOrgList}"
								value="${areavo.bottomOrg.coWorkerID}"
								onChange="onChangeEventHandle(this,'STREETORG')"
								style="width:150px"
								>
                            </pms:unitedSelect>
                            </td>
                            <td class="aux_intable_td1">${key.house_bottomOrg_telephone}：</td>
                            <td class="aux_intable_td2" id="bottomOrg_telephone">${areavo.bottomOrg.telephone}</td>
                          </tr>
                          <tr>
                            <td class="aux_intable_td1">${key.house_bottomOrg_contactor}：</td>
                            <td class="aux_intable_td2" id="bottomOrg_contactor">${areavo.bottomOrg.contactor}</td>
                            <td class="aux_intable_td1">${key.house_bottomOrg_address}：</td>
                            <td class="aux_intable_td2" id="bottomOrg_address">${areavo.bottomOrg.address}</td>
                          </tr>

                        </table>
                        </td>
                      </tr>

                </table>
                        </td>
                      </tr>
                </table>
              </div>
</form>
</body>